<template>
	<view>
		<view>
			<systemHVue :title='value'>
				<u-icon style="margin-left: 20rpx;" @click="addZhiwei" v-if="value=='职位' && userType == 'user'"
					color="#fff" size="22" name="plus"></u-icon>
				<u-icon style="margin-left: 20rpx;" @click="addRencai" v-if="value=='人才' && userType == 'user'"
					color="#fff" size="22" name="plus"></u-icon>
					<u-icon style="margin-left: 20rpx;" @click="addRencai" v-if="value=='预支管理' && userType == 'user'"
						color="#fff" size="22" name="plus"></u-icon>
			</systemHVue>
			<view v-if="value=='职位'">
				<position></position>
			</view>
			<view v-if="value == '人才'">
				<talent></talent>
			</view>
			<view v-if="value == '薪资确认'">
				<xinZiQueRenVue></xinZiQueRenVue>
			</view>
			<view v-if="value == '出勤情况'">
				<chuQinVue></chuQinVue>
			</view>
			<view v-if="value=='招聘跟进'">
				<followUp></followUp>
			</view>
			<view v-if="value=='预支管理'">
				<yuZhiVue></yuZhiVue>
			</view>
			<view v-if="value=='消息' && userType=='user'">
				<!-- <staff></staff> -->
				<massage></massage>
			</view>
			<view v-if="value=='消息' && userType=='talent'">
				<!-- <staff></staff> -->
				<yuanGongMassageVue></yuanGongMassageVue>
			</view>
			<view v-if="value=='我的'">
				<my></my>
			</view>
		</view>
		<u-tabbar :value="value" @change="name => value = name" :fixed="true" activeColor='#44af85' :placeholder="true"
			:safeAreaInsetBottom="true">
			<u-tabbar-item v-for="(item,index) in tabbar[role]" :key="index" :text="item.text" :name='item.name'
				:icon="item.icon"></u-tabbar-item>
		</u-tabbar>
	</view>
</template>

<script>
	import yuZhiVue from '@/components/yuZhiManagement/yuZhi.vue'
	import xinZiQueRenVue from '@/components/xinZiQueRen/xinZiQueRen.vue'
	import chuQinVue from '@/components/chuQin/chuQin.vue'
	import position from '@/components/position/position.vue'
	import talent from '@/components/talent/talent.vue'
	import followUp from '@/components/followUp/followUp.vue'
	import staff from '@/components/staff/staff.vue'
	import massage from '@/components/massage/massage.vue'
	import yuanGongMassageVue from '@/components/massage/yuanGongMassage.vue'
	import my from '@/components/my/my.vue'
	import systemHVue from '@/components/systemH/systemH.vue'
	import {
		getUserType
	} from '@/utils/auth'
	export default {
		components: {
			position,
			talent,
			followUp,
			staff,
			my,
			systemHVue,
			massage,
			xinZiQueRenVue,
			chuQinVue,
			yuanGongMassageVue,
			yuZhiVue
		},
		data() {
			return {
				value: '',
				userType: '',
				// onSite：驻场人员  agent：代理商 hire:招聘 staff：人员
				role: 'onSite',
				tabbar: {
					'onSite': [
						{text:'职位',icon:'home',name:"职位"},
						{text:'人才',icon:'account',name:"人才"},
						{text:'薪资确认',icon:'account',name:"薪资确认"},
						{text:'出勤情况',icon:'account',name:"出勤情况"},
						{text:'招聘跟进',icon:'photo',name:"招聘跟进"},
						{text:'预支管理',icon:'photo',name:"预支管理"},
						{text:'消息',icon:'play-right',name:"消息"},
						{text:'员工',icon:'play-right',name:"员工"},
						{text:'我的',icon:'account',name:"我的"},
					]
				}
			}
		},
		onLoad() {
		
			let userType = getUserType()
			this.userType = userType
			console.log(userType, "userType")
			
			if (userType == 'user') { //招聘人员
				this.value = "职位"
				this.tabbar.onSite = [{
						text: '职位',
						icon: 'home',
						name: "职位"
					},
					{
						text: '人才',
						icon: 'account',
						name: "人才"
					},
					{
						text: '招聘跟进',
						icon: 'photo',
						name: "招聘跟进"
					},
					{
						text: '消息',
						icon: 'play-right',
						name: "消息"
					},
					{
						text: '我的',
						icon: 'account',
						name: "我的"
					},
				]
			} else if (userType == 'talent') { //应聘者
				this.value = "职位"
				this.tabbar.onSite = [{
						text: '职位',
						icon: 'home',
						name: "职位"
					},
					{
						text: '消息',
						icon: 'play-right',
						name: "消息"
					},
					{
						text: '我的',
						icon: 'account',
						name: "我的"
					},
				]
			} else if (userType == 'employee') { //员工
				this.value = "薪资确认"
				this.tabbar.onSite = [{
						text: '薪资确认',
						icon: 'account',
						name: "薪资确认"
					},
					{
						text: '出勤情况',
						icon: 'account',
						name: "出勤情况"
					},
					{
						text: '预支管理',
						icon: 'account',
						name: "预支管理"
					},
					{
						text: '我的',
						icon: 'account',
						name: "我的"
					},
				]
			} else {
				this.value = "职位"
				this.tabbar.onSite = [{
						text: '职位',
						icon: 'home',
						name: "职位"
					},
					{
						text: '我的',
						icon: 'account',
						name: "我的"
					},
				]
			}
		},
		methods: {
			addZhiwei() {
				uni.navigateTo({
					url: "/pages/addZhiWei/addZhiWei"
				})
			},
			addRencai() {
				uni.navigateTo({
					url: "/pages/geRenXinXi/geRenXinXi?type=rencai"
				})
			}
		}
	}
</script>

<style>

</style>